package com.xenstra.bhavcopydownloader;

import java.io.File;
import java.util.Date;
import java.util.List;

/**
 * This class can be executed to download and upload the current date's bhavcopy into the DB.
 *
 */
public class DailySync {

	@SuppressWarnings("deprecation")
	public static void main(String[] args) throws Exception{
		String folder = "G:\\bhavcopies";
		Date today = new Date();
		today = new Date(today.getYear(), today.getMonth(), today.getDate());
		BhavCopyDownloader.main(new String[]{folder});

		BhavCopyDBUploader uploader = new BhavCopyDBUploader();
		uploader.init();
		//List<File> files = Utils.getAllFilesInFolder(folder, fileExtWildCard);
		List<File> files = Utils.getAllFilesInFolder(folder, today, today);
		System.out.println("\n" + files.size() + " files in " + folder);

		for(File file : files){
			uploader.uploadToDB(file, true, true);
		}			
	}

}
